{
	template:`
	<a-page-header title="编辑" sub-title="汇总表">
		<template #extra>
			<a-button type="primary" @click="save();">保存</a-button>
			<m-back @click="back(false);">关闭</m-back>
		</template>
		<a-card :hoverable="true" :bodyStyle="{padding:'20px 20px 0'}">
			<a-form class="index-form" :wrapper-col="{span:24}">
				<a-row :gutter="10">
					<a-col :span="16">
						<a-form-item label="描述" class="index-form-item">
							<a-input v-model:value="model.description" placeholder="请输入描述"/>
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item label="功能" class="index-form-item">
							<a-checkbox-group :options="dictOptions('api.model.ApiCollect!functions')" v-model:value="model.functions" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item label="标题" class="index-form-item">
                            <a-input v-model:value="model.title" placeholder="请输入标题"/>
						</a-form-item>
					</a-col>
					<a-col :span="16">
						<a-form-item label="子标题" class="index-form-item">
							<a-input v-model:value="model.subTitle" placeholder="请输入子标题"/>
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item label="来源" class="index-form-item">
							<a-radio-group :options="sourceList" v-model:value="model.source"/>
						</a-form-item>
					</a-col>
					<a-col v-if="model.source=='table'" :span="8">
						<a-form-item label="数据表" class="index-form-item">
							<a-select :options="tableList" v-model:value="model.table.oid" placeholder="请选择数据表" show-search :filter-option="selectFilter" />
						</a-form-item>
					</a-col>
					<a-col v-if="model.source=='collect'" :span="8">
						<a-form-item label="汇总表" class="index-form-item">
							<a-select :options="collectList" v-model:value="model.collect.oid" placeholder="请选择汇总表" show-search :filter-option="selectFilter" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item label="别名" class="index-form-item">
                            <a-tooltip title="只能输入小写字母数字和下划线">
                                <a-input v-model:value="model.alias" placeholder="请输入别名"/>
                            </a-tooltip>
						</a-form-item>
					</a-col>
					<a-col :span="16">
						<a-form-item label="SQL条件" class="index-form-item">
						    <a-button type="primary" @click="inputTestField('sqlCondition')" :disabled="!model.oid">输入</a-button>
						    <a-button v-if="model.sqlCondition" @click="model.sqlCondition='';" type="link">清除</a-button>
                            {{model.sqlCondition}}
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item label="序号列" class="index-form-item">
							<a-radio-group :options="indexOptions" v-model:value="model.showIndexColumn" />
						</a-form-item>
					</a-col>
					<a-col :span="16">
						<a-form-item label="SQL排序" class="index-form-item">
						    <a-button type="primary" @click="inputTestField('sqlOrder')" :disabled="!model.oid">输入</a-button>
                            <a-button v-if="model.sqlOrder" @click="model.sqlOrder='';" type="link">清除</a-button>
                            {{model.sqlOrder}}
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item label="合并开始列" class="index-form-item-lg">
							<a-input-number v-model:value="model.scol" placeholder="请输入合并开始列" style="width:100%"/>
						</a-form-item>
					</a-col>
					<a-col :span="16">
						<a-form-item label="聚合条件" class="index-form-item">
						    <a-button type="primary" @click="inputTestField('sqlHaving')" :disabled="!model.oid">输入</a-button>
                            <a-button v-if="model.sqlHaving" @click="model.sqlHaving='';" type="link">清除</a-button>
                            {{model.sqlHaving}}
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item label="合并列长度" class="index-form-item-lg">
							<a-input-number v-model:value="model.slength" placeholder="请输入合并列长度" style="width:100%"/>
						</a-form-item>
					</a-col>
				</a-row>
			</a-form>
		</a-card>
	</a-page-header>
	<div id="apiCollect_join" style="min-height:15px;margin-top:-15px;">
	</div>
	<div id="apiCollect_column" style="min-height:15px;margin-top:-15px;">
	</div>
	`,
	props: ['localeZh','param','parentVue'],
	data:function(){
		return {
		    model:{table:{},collect:{}},
		    sourceList:[{label:'数据表',value:'table'},{label:'汇总表',value:'collect'}],
		    tableList:[],
		    collectList:[],
		    indexOptions:[{label:'显示',value:'Y'},{label:'不显示',value:'N'}],

		};
	},
	mounted(){
	    this.model=this.param.model;
	    this.tableList=this.param.tableList;
	    this.collectList=this.param.collectList;
	    this.initOther();
	},
	methods:{
		save:function(){
			this.requestData('action/api/apiCollect/doSave',
				{model:this.model},
				data=>{
					if(data.code==0){
						this.$message.success(data.msg);
						this.model=data.model;
						this.setBack(true);
						this.initOther();
					}else{
						this.$message.error(data.msg);
					}
				}
			);
		},
		initOther:function(){//初始化
			if(this.model.oid){
                this.loadPage("apiCollect_join",
                    "action/api/apiCollect/apiCollectJoin",
                    {params:{"apiCollect.oid":this.model.oid}},
                    function(pv,v3){}.bind(this)
                );
                this.loadPage("apiCollect_column",
                    "action/api/apiCollect/apiCollectColumn",
                    {params:{"collect.oid":this.model.oid}},
                    function(pv,v3){}.bind(this)
                );
			}
		},
		inputTestField:function(field){
            this.openPage('page/base/api/inputTestField.js',
                {value:this.model[field],collectOid:this.model.oid,
                    temps:["#{字段}"]},
                function(flag,obj){
                    if(flag){
                        this.model[field]=obj;
                    }
                },
                "800px"
            );
		}
	}
}